import React, { Component } from 'react'
import {connect} from "react-redux" // connect可以可以将仓库中的数据在组件中获取
import {bindActionCreators} from "redux" // 将抽离出去的action合并进来
import * as action from "../action"
class Myclass extends Component {
    componentDidMount() {
        console.log(this.props);
        this.props.getlist()
    }
    fn () {
        this.props.setName()
    }
  render() {
    return (
      <div>{this.props.name}
        <button onClick={this.fn.bind(this)}>修改name</button>
        <hr />
            {
                this.props.arr && this.props.arr.length? this.props.arr.map((item,index)=>{
                    return <div key={index}>{item.Name}</div>
                }):"暂无数据"
            }
        <hr />
      </div>
    )
  }
}
let mapStateToprops = (state)=>{
     console.log(state,11111);
        return {
            ...state.appreducer
        }
}
let mapDispatchToprops = (dispatch)=>bindActionCreators(action,dispatch)
// 函数科里话加高阶组件得写法
export default connect(mapStateToprops,mapDispatchToprops)(Myclass)